<template>
  <div v-if="show">
    <p>默认初始值：{{show}},显示</p>
    <button @click="closeDiv">关闭</button>
  </div>
</template>

<script>
export default {
  name: "myComponent",
  props: ['show'],
  methods: {
    closeDiv(){
      this.$emit("update:show", false)// 触发input事件，并传入新值
    }
  }
}
</script>

<style scoped>

</style>